<?php
include("twitteroauth/twitteroauth.php");
session_start();

error_reporting(E_ALL);
ini_set('display_errors', 'On');

    // The TwitterOAuth instance
$twitteroauth = new TwitterOAuth('6w9YqMhlUxS6tL1WubERGQ', 'BHlIB2UXBZNE12l41j2uJ0ggy0W0IQ90wjSplnLNE');
// Requesting authentication tokens, the parameter is the URL we will be redirected to
$request_token = $twitteroauth->getRequestToken('http://pluto.cse.msstate.edu/~dcspg8/dcsp-portal-project/twitter_oauth.php');

// Saving them into the session
$_SESSION['oauth_token'] = $request_token['oauth_token'];
$_SESSION['oauth_token_secret'] = $request_token['oauth_token_secret'];

// If everything goes well..
if($twitteroauth->http_code==200){
    // Let's generate the URL and redirect
    $url = $twitteroauth->getAuthorizeURL($request_token['oauth_token']);
    header('Location: '. $url);
} else {
    // It's a bad idea to kill the script, but we've got to know when there's an error.
    die('Something wrong happened.');
}

?>
